package me.firstapp.module.weixin.weibi;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;

import me.firstapp.module.base.BaseEntity;
import me.firstapp.module.weixin.system.AccountRecordType;

@Entity
@Table(name = "WEIBI_ACCOUNT_TRACE")
public class WeiBiAccountTrace extends BaseEntity {

	private static final long serialVersionUID = 2397631822725281328L;

	/**
	 * 积分账户ID
	 */
	@Column(name = "WEIBI_ACCOUNT_ID", nullable = false)
	private Long weiBiAccountId;

	/**
	 * 变动类型
	 */
	@Enumerated(value = EnumType.STRING)
	@Column(name = "CHANGE_TYPE")
	private ChangeType changeType;

	/**
	 * 变动前积分值
	 */
	@Column(name = "BEFORE_VALUE", columnDefinition = ("DECIMAL(11,4) "), nullable = false)
	private BigDecimal beforeValue;

	/**
	 * 变动值
	 */
	@Column(name = "CHANGE_VALUE", columnDefinition = ("DECIMAL(11,4) "), nullable = false)
	private BigDecimal changeValue;

	/**
	 * 变动后积分值
	 */
	@Column(name = "AFTER_VALUE", columnDefinition = ("DECIMAL(11,4) "), nullable = false)
	private BigDecimal afterValue;

	/**
	 * 变动日期
	 */
	@Column(name = "CHANGE_DATE", nullable = false)
	private Integer changeDate;

	/**
	 * 变动时间
	 */
	@Column(name = "CHANGE_TIME", columnDefinition = "DATETIME", nullable = false)
	private Date changeTime;

	public enum ChangeType {
		SELF_CONSUME_ADD(AccountRecordType.ADD, 1, "消费赠送"), 
		FANS_CONSUME_ADD(AccountRecordType.ADD, 2,"销售赠送"), 
		JINBI_SUB_WEIBI(AccountRecordType.SUB, 3,"兑换贝币"), 
		SYS_GIVE_ADD(AccountRecordType.ADD, 5, "系统赠送"),
		HANDLE_ADD(AccountRecordType.ADD, 6, "手工调整(增)"),
		HANDLE_SUB(AccountRecordType.SUB, 7, "手工调整(减)"),
		SPREAD_ADD(AccountRecordType.ADD, 8, "推广赠送"),
		RETURN_SUB(AccountRecordType.SUB, 9, "退货/款扣减"),
		J_RETURN_SUB(AccountRecordType.SUB, 10, "顾客退货/款");
		AccountRecordType accountRecordType;
		String id;
		String desc;

		ChangeType(AccountRecordType accountRecordType, Integer id, String desc) {
			this.id = String.valueOf(id);
			this.desc = desc;
			this.accountRecordType = accountRecordType;
		}

		public AccountRecordType getAccountRecordType() {
			return accountRecordType;
		}

		public String getId() {
			return id;
		}

		public String getDesc() {
			return desc;
		}
	}

	public Long getWeiBiAccountId() {
		return weiBiAccountId;
	}

	public void setWeiBiAccountId(Long weiBiAccountId) {
		this.weiBiAccountId = weiBiAccountId;
	}

	public ChangeType getChangeType() {
		return changeType;
	}

	public void setChangeType(ChangeType changeType) {
		this.changeType = changeType;
	}

	public BigDecimal getBeforeValue() {
		return beforeValue;
	}

	public void setBeforeValue(BigDecimal beforeValue) {
		this.beforeValue = beforeValue;
	}

	public BigDecimal getChangeValue() {
		return changeValue;
	}

	public void setChangeValue(BigDecimal changeValue) {
		this.changeValue = changeValue;
	}

	public BigDecimal getAfterValue() {
		return afterValue;
	}

	public void setAfterValue(BigDecimal afterValue) {
		this.afterValue = afterValue;
	}

	public Date getChangeTime() {
		return changeTime;
	}

	public void setChangeTime(Date changeTime) {
		this.changeTime = changeTime;
	}

	public Integer getChangeDate() {
		return changeDate;
	}

	public void setChangeDate(Integer changeDate) {
		this.changeDate = changeDate;
	}

}
